<?php
namespace Admin\Controller;
class AdminController extends AdminBaseController {
   /***
    *@privilege Admin:管理员->添加:53544650745
    */
    public function add()
    {
        if(IS_POST){
            $data = I('post.');
            if(empty($data['upass'])){
                $this->error('密码不能为空');
            }
            $data['upass'] = password_hash($data['upass'],PASSWORD_DEFAULT);
            $this->_addData('Admin',$data);
        }else{
            $roleList = D('Role')->getAllRoles();
            $this->assign([
                'roleList' =>$roleList
            ]);
            $this->_display('edit','管理员增加');
        }
    }
    /***
    *@privilege Admin:管理员->编辑:31484646274
    */
    public function edit()
    {
        if(IS_POST){
            $data = I('post.');
            if(!empty($data['upass'])){
                $data['upass'] = password_hash($data['upass'],PASSWORD_DEFAULT);
            }
            $this->_editData('Admin',$data);
        }else{
            $info = $this->_detail('Admin');
            $roleList = D('Role')->getAllRoles();
            $this->assign([
                'info' => $info,
                'roleList' =>$roleList
            ]);
            $this->_display('edit','管理员编辑');
        }
    }
    /***
    *@privilege Admin:管理员->列表:90697797646
    */
    public function lis()
    {
        $where = 1;
        $result = $this->_list('Admin',$where,10);
        $this->assign($result);
        $roleList = D('Role')->getAllRoles();
        $this->assign([
            'roleList' =>$roleList
        ]);
        $this->_display('lis','管理员列表');
    }
    /***
    *@privilege Admin:管理员->删除:13578901692
    */
    public function del()
    {
        $this->_delAll('Admin');
    }

}